<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 题目3: 实现数组的去重, 传入需要去重的纯数字数组,将数组去重,返回数组元素不重复的数组
    函数名：noRepeatArray
    参数：需要去重的纯数字数组
    返回值：去重后的数组
    例如：noRepeatArray([3,3,1,5,1,2]) 返回 [3, 1, 5, 2] -->
</body>

</html>
<script>
    function noRepeatArray(arr) {
        let newArr = [];
        for (let i = 0; i < arr.length; i++) {
            if (newArr.indexOf(arr[i]) == -1) {
                newArr.push(arr[i]);
            }
        }
        return newArr
    }
    console.log(noRepeatArray([3, 3, 1, 5, 1, 2]));
</script>